//
//  Homework.swift
//  SwiftUIStacks
//
//  Created by 李煜 on 2024/7/31.
//

import SwiftUI

struct Homework: View {
    var body: some View {
        Spacer()

        ZStack {
            CardView(icon: "wand.and.stars", title: "Basic", price: "$9", bgColor: .purple)

            ZStack {
                CardView(icon: "wand.and.stars", title: "Pro", price: "$19", bgColor: .orange)
                CardView(icon: "wand.and.stars", title: "Team", price: "$299", bgColor: Color(red: 62 / 255, green: 63 / 255, blue: 70 / 255), scaleFactor: 0.5)
                    .offset(x: 0, y: -160)
                    .padding(.horizontal, 20)
            }
            .offset(x: 0, y: -160)
            .padding(.horizontal, 20)
        }
        .padding(.horizontal, 16)
        .padding(.bottom, 20)
    }
}

#Preview {
    Homework()
}

struct CardView: View {
    var icon: String
    var title: String
    var price: String
    var bgColor: Color
    var scaleFactor: Float = 1
    var body: some View {
        VStack {
            Image(systemName: icon)
                .font(.largeTitle)
                .foregroundColor(.white)
            Text(title)
                .foregroundStyle(.white)
				.fontWeight(.black)
				.font(.system(.title, design: .rounded))
            Text(price)
                .foregroundStyle(.white)
                .font(.system(size: 40, weight: .black, design: .rounded))
            Text("per month")
                .foregroundStyle(.white)
                .font(.system(.title, design: .rounded))
        }
        .frame(minWidth: 0, maxWidth: .infinity)
        .padding()
        .background(bgColor)
        .cornerRadius(10)
    }
}
